/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.jjsoft.celularessuc.gco.mdl;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import org.codehaus.jackson.annotate.JsonIgnore;

/**
 *
 * @author Johnny
 */
@Entity
@Table(catalog = "celularessuccom", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Proforma.findAll", query = "SELECT p FROM Proforma p"),
    @NamedQuery(name = "Proforma.findByIdProforma", query = "SELECT p FROM Proforma p WHERE p.idProforma = :idProforma"),
    @NamedQuery(name = "Proforma.findByNumero", query = "SELECT p FROM Proforma p WHERE p.numero = :numero"),
    @NamedQuery(name = "Proforma.findByFechaEmision", query = "SELECT p FROM Proforma p WHERE p.fechaEmision = :fechaEmision"),
    @NamedQuery(name = "Proforma.findByTotal", query = "SELECT p FROM Proforma p WHERE p.total = :total"),
    @NamedQuery(name = "Proforma.findByEstado", query = "SELECT p FROM Proforma p WHERE p.estado = :estado"),
    @NamedQuery(name = "Proforma.findByDescuento", query = "SELECT p FROM Proforma p WHERE p.descuento = :descuento"),
    @NamedQuery(name = "Proforma.findByIva", query = "SELECT p FROM Proforma p WHERE p.iva = :iva"),
    @NamedQuery(name = "Proforma.findBySubtotal", query = "SELECT p FROM Proforma p WHERE p.subtotal = :subtotal")})
public class Proforma implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(nullable = false)
    private Integer idProforma;
    @Basic(optional = false)
    @Column(nullable = false)
    private int numero;
    @Column(name = "fecha_emision")
    @Temporal(TemporalType.DATE)
    private Date fechaEmision;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(precision = 22)
    private Double total;
    private Integer estado;
    @Column(precision = 22)
    private Double descuento;
    @Column(precision = 22)
    private Double iva;
    @Column(precision = 22)
    private Double subtotal;
    @JoinColumn(name = "cedula_cliente", referencedColumnName = "cedula", nullable = false)
    @ManyToOne(optional = false)
    private Cliente cedulaCliente;
    @JoinColumn(name = "idSucursal", referencedColumnName = "idsucursal")
    @ManyToOne
    private Sucursal idSucursal;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idProforma")
    private List<Detalleproforma> detalleproformaList;

    public Proforma() {
    }

    public Proforma(Integer idProforma) {
        this.idProforma = idProforma;
    }

    public Proforma(Integer idProforma, int numero) {
        this.idProforma = idProforma;
        this.numero = numero;
    }

    public Integer getIdProforma() {
        return idProforma;
    }

    public void setIdProforma(Integer idProforma) {
        this.idProforma = idProforma;
    }

    public int getNumero() {
        return numero;
    }

    public void setNumero(int numero) {
        this.numero = numero;
    }

    public Date getFechaEmision() {
        return fechaEmision;
    }

    public void setFechaEmision(Date fechaEmision) {
        this.fechaEmision = fechaEmision;
    }

    public Double getTotal() {
        return total;
    }

    public void setTotal(Double total) {
        this.total = total;
    }

    public Integer getEstado() {
        return estado;
    }

    public void setEstado(Integer estado) {
        this.estado = estado;
    }

    public Double getDescuento() {
        return descuento;
    }

    public void setDescuento(Double descuento) {
        this.descuento = descuento;
    }

    public Double getIva() {
        return iva;
    }

    public void setIva(Double iva) {
        this.iva = iva;
    }

    public Double getSubtotal() {
        return subtotal;
    }

    public void setSubtotal(Double subtotal) {
        this.subtotal = subtotal;
    }

    public Cliente getCedulaCliente() {
        return cedulaCliente;
    }

    public void setCedulaCliente(Cliente cedulaCliente) {
        this.cedulaCliente = cedulaCliente;
    }

    public Sucursal getIdSucursal() {
        return idSucursal;
    }

    public void setIdSucursal(Sucursal idSucursal) {
        this.idSucursal = idSucursal;
    }

    @XmlTransient
    @JsonIgnore
    public List<Detalleproforma> getDetalleproformaList() {
        return detalleproformaList;
    }

    public void setDetalleproformaList(List<Detalleproforma> detalleproformaList) {
        this.detalleproformaList = detalleproformaList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idProforma != null ? idProforma.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Proforma)) {
            return false;
        }
        Proforma other = (Proforma) object;
        if ((this.idProforma == null && other.idProforma != null) || (this.idProforma != null && !this.idProforma.equals(other.idProforma))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.jjsoft.celularessuc.gco.mdl.Proforma[ idProforma=" + idProforma + " ]";
    }
    
}
